{% extends 'myadmin/base.html' %}

{% block main_body %}
<div style="height:60px">

</div>
 <div class="card-header">
     <h3 class="card-title"><a href="{% url 'myadmin_index' %}">首页</a> >> <a href="{% url 'myadmin_user_index' %}?index=6">用户信息管理</a> >> 用户添加</h3>
 </div>
<div style="width:70%; margin-left:15%;">
 <div class="card card-primary">
              <div class="card-header">
                <h3 class="card-title">用户添加</h3>
              </div>
              <!-- /.card-header -->
              <!-- form start -->
              <form action="{% url 'myadmin_user_insert' %}" method="post">
                  {% csrf_token %}
                <div class="card-body">
                  <div class="form-group">
                    <label for="username">用户姓名</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户姓名">
                  </div>
                  <div class="form-group">
                    <label for="passwd">用户密码</label>
                    <input type="password" class="form-control" id="userpwd" name="userpwd" placeholder="请输入用户密码">
                  </div>
                    <div class="form-group">
                    <label for="passwd1">确认密码</label>
                    <input type="password" class="form-control" id="userpwd2" name="userpwd2"  placeholder="请确认用户密码">
                  </div>
                    <div class="form-group">
                    <label for="nickname">用户昵称</label>
                    <input type="text" class="form-control" id="nickname" name="nickname" placeholder="请输入用户昵称">
                  </div>
                     <div class="form-group">
                    <label for="age">用户年龄</label>
                    <input type="text" class="form-control" name="age" id="age" placeholder="请输入用户年龄">
                  </div>


                </div>
                <!-- /.card-body -->

                <div class="card-footer">
                  <button type="submit" class="btn btn-primary" onclick="return check();">提交</button>
                    &nbsp; &nbsp;
                    <button type="reset" class="btn btn-primary">重置</button>
                </div>
              </form>
            </div>
</div>
<script>
    function check(){
         username = document.getElementById('username').value;
         userpwd = document.getElementById('userpwd').value;
         userpwd2 = document.getElementById('userpwd2').value;
         age = document.getElementById('age').value;
         info="";

         if(username==""){
            info="用户姓名不能为空！！\n"
         }
         if(userpwd==""){
            info=info+"用户密码不能为空！！\n"
         }
         if(userpwd!=userpwd2){
            info=info+"两次输入的密码不一样！！\n"
         }
         if(age==""){
            info=info+"用户年龄不能为空！！\n"
         }
         if(info!=""){
            alert(info);
            return false;
         }

         return true;

    }
</script>

{% endblock %}